package com.ruibang.glass.material.controller.container;

import com.ruibang.glass.material.domain.req.ContainerManagerReq;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.material.domain.req.ContainerTransferReq;
import com.ruibang.glass.material.entity.GlassContainerManager;
import com.ruibang.glass.material.service.GlassContainerManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.validation.Valid;


/**
 * <p>
 * 容器管理表 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-25
 */
@RestController
@RequestMapping("/api/material/container/manager")
public class GlassContainerManagerController {

    @Autowired
    private GlassContainerManagerService glassContainerManagerService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取容器", notes = "获取容器管理表")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(glassContainerManagerService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增容器", notes = "新增容器管理表")
    public ResultBody save(@RequestBody @Valid GlassContainerManager containerManager) {
        glassContainerManagerService.insert(containerManager);
        return ResultBody.success();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改容器", notes = "修改容器管理表")
    public ResultBody edit(@RequestBody GlassContainerManager containerManager) {
        glassContainerManagerService.edit(containerManager);
        return ResultBody.success();
    }

    @PostMapping("/list")
    @ApiOperation(value = "非分页列表查询容器", notes = "非分页列表查询容器管理表")
    public ResultBody list() {
        return ResultBody.success(glassContainerManagerService.list());
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询容器", notes = "分页列表查询容器管理表")
    public ResultBody<IPage<GlassContainerManager>> pageQuery(@RequestBody ContainerManagerReq containerManagerReq) {
        return ResultBody.success(glassContainerManagerService.pageQuery(containerManagerReq));
    }

    @PostMapping("/transfer")
    @ApiOperation(value = "容器转移", notes = "容器转移")
    public ResultBody transfer(@RequestBody @Valid ContainerTransferReq containerTransferReq) {
        return glassContainerManagerService.transfer(containerTransferReq);
    }
}
